#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  if (k >= n - 1)
  {
    cout << 0;
    return 0;
  }
  vector<long long> everyRoad(n - 1, 0);
  for (auto &x : everyRoad)
    cin >> x;
  for (int i = 1; i < everyRoad.size(); i++)
    everyRoad[i] = everyRoad[i] + everyRoad[i - 1];
  long long ans = 0;
  for (int i = 0; i + k < everyRoad.size(); i++)
    ans = max(everyRoad[i + k] - everyRoad[i], ans);
  cout << everyRoad[everyRoad.size() - 1] - ans;
  return 0;
}